

import queue
import requests
import json
import time

print(time.strftime("%Y-%m-%d-%H_%M_%S", time.localtime()))
print("loading........")

queueOne = queue.Queue()
list=[]

text_line=None

# print(type(list))

file =open("urlList2.txt", "r")

try:
    while True:
        text_line = file.readline()
        # print(text_line)
        if text_line:
            list.append(text_line)
        else:
            break
finally:
    file.close()


# n=len(list)

for link in list:
    data= requests.get(link.replace('\n',''))

    body = json.loads(data.text)

    print(body)
    queueOne.put(body)

# print(queueOne.get())
# print(queueOne.get())
# print(queueOne.get())

file1 = open("2017urls.txt","a+")

while queueOne.empty() != True:
    file1.write(str(queueOne.get())+"\n")

file1.close()

print(time.strftime("%Y-%m-%d-%H_%M_%S", time.localtime()))

# data = requests.get(file.readline())
# #
# body = json.loads(data.text)
# queueOne.put(body)
# print(queueOne.get())
